package com.pt25.service.sys.interfaces.facade.rpc;


import com.pt25.base.dep.nacos.rpc.aspect.RpcCheck;
import com.pt25.base.res.ResBody;
import com.pt25.service.sys.rpc.SysRpcApi;
import com.pt25.service.sys.rpc.vo.RpcTestVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Tag(name = "(rpc)im应用管理")
@RestController
@RequestMapping("/")
public class SysRpcController implements SysRpcApi {

    @RpcCheck
    @Override
    public ResBody testRpc(RpcTestVo rpcTestVo) {
        //定义异常，测试失败返回SysRpcAPIFallback
        //int i = 1 / 0;
        //测试超时时间
        try {
            log.info("execute testRpc! rpcTestVo={}", rpcTestVo);
            Thread.sleep(rpcTestVo.getExpiredTimes());
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        return ResBody.builder().data(rpcTestVo).build();
    }
}
